import { Notification, MessageBox, Message, Loading } from 'element-ui'

export function ResultMessage(response, showMsg = true) {
    const data = response.data
    if (data.status === 200) {
        if (showMsg) {
            Notification({
                type: 'success',
                duration: 2000,
                title: '提示',
                message: data.statusText
            })
        }
        return true
    } else if (data.status === 601) {
        Notification({
            type: 'warning',
            duration: 2000,
            title: '提示',
            message: data.msg
        })
        return false
    } else if (data.status === 602) {
        Notification({
            type: 'error',
            duration: 2000,
            title: '操作失败',
            message: data.msg
        })
        return false
    } else if (data.status === 412) {
        //用户登录超时，由http模块弹出对话框消息，这里不做处理
        return false
    } else {
        MessageBox({
            type: 'error',
            title: '程序异常',
            message: data.msg
        })
        return false
    }
}